<!doctype html>
<html class="no-js">

<head>
    <title>确认订单</title>
    <#include "/fd/components/meta.html" />
    <#include "/fd/components/stylesheets.html" />
    <link rel="stylesheet" type="text/css" href="/fd/stylesheets/quest.css">
</head>

<body>
    <div id="app">
        <!-- <ul class="am-avg-sm-5 top-now">
            <li>
                <div>选择问题</div>
            </li>
            <li>
                <div>确定订单</div>
            </li>
            <li>
                <div>完成支付</div>
            </li>
            <li>
                <div>填写信息</div>
            </li>
            <li>
                <div>等待回复</div>
            </li>
        </ul> -->
        <div class="am-form" action="/fd/fakePay">
            <input type="hidden" name="orderNo" value="${order.orderNo!''}">
            <fieldset>
                <div class="am-panel am-panel-default confirm-panel">
                    <div class="am-panel-hd confirm-panel-header">订单信息</div>
                    <div class="am-panel-bd confirm-panel-body">
                        <div class="order-content-container">
                            <span>${content!''}</span>
                        </div>
                        <div class="order-id-container">
                            <div>订单编号</div>
                            <div>${order.orderNo!''}</div>
                        </div>
                        <div class="order-time-container">
                            <div>下单时间</div>
                            <div>${order.addTime!''}</div>
                        </div>
                    </div>
                </div>
                <div class="am-panel am-panel-default confirm-panel">
                    <div class="am-panel-hd confirm-panel-header">支付信息</div>
                    <div class="am-panel-bd confirm-panel-body">
                        <div class="order-price-container">
                            <div>订单金额</div>
                            <div>￥${(order.price*0.01)!}</div>
                        </div>
                    </div>
                </div>
                <div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default bottom-bar">
                    <button type="submit" class="am-btn am-btn-primary" id="next-button" @click='onPay("${order.orderNo!""}")'>确认支付</button>
                </div>
            </fieldset>
        </div>
    </div>
    <#include "/fd/components/scripts.html" />
    <#include "/fd/components/http.html" />
    <#include "/fd/components/wxConfig.html" />
    <script type="text/javascript" src="http://lib.h-ui.net/jquery.cookie/1.4.1/jquery.cookie.js"></script>
    <!-- <script type="text/javascript" src="/fd/js/orderConfirm.js"></script> -->
    <script type="text/javascript">
    wx.ready(function() {
        initWXShareAll('品学22联萌', "蓁奕22科技", "http://app.cenjiawen.com/fd/", "https://tva1.sinaimg.cn/crop.107.20.332.332.180/6b57de11gw1enhnf5qp8ij20c80c8767.jpg");
    });
    </script>
    <script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            questionContent: '',
            masterId: ''
        },
        created: function() {
            this.questionContent = $.cookie('questionContent')
            this.masterId = $.cookie('masterId')
            // this.content = questionContent
        },
        methods: {
            onPay: function(orderNo) {
                wx.chooseWXPay({
                    timestamp: "${packageParams.timeStamp!''}", // 支付签名时间戳，注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
                    nonceStr: "${packageParams.nonceStr!''}", // 支付签名随机串，不长于 32 位
                    package: "${packageParams.package!''}", // 统一支付接口返回的prepay_id参数值，提交格式如：prepay_id=\*\*\*）
                    signType: "${packageParams.signType!''}", // 签名方式，默认为'SHA1'，使用新版支付需传入'MD5'
                    paySign: "${packageParams.paySign!''}", // 支付签名
                    success: function(res) {
                        window.location.href = '/fd/orderStatus?orderNo=' + orderNo;
                    }
                });
            },
            onFakePay: function(orderNo) {
                var param = {
                    orderNo: orderNo
                }
                fly.request('/fd/pay', param, {
                        method: "post",
                    })
                    .then(function(response) {
                        layer.closeAll();
                        var status = response.data.status
                        var msg = response.data.msg
                        if (status == 200) {
                            // var orderNo = response.data.info
                            window.location.href = '/fd/orderStatus?orderNo=' + orderNo;
                            return;
                        } else {
                            layer.open({
                                content: msg,
                                btn: '我知道了'
                            });
                        }
                    })
                    .catch(function(error) {
                        console.log(error);
                    });
            }

        }
    })
    </script>
</body>

</html>